package org.dubh.problems;

public final class AsciiToInt {
    private AsciiToInt() {}
    
    public static int asciiToInt( String s ) {
        int result = 0;
        for ( int i=0; i < s.length(); i++ ) {
            char c = s.charAt( i );
            int value = c - 48;
            if ( value < 0 || value > 9 ) return result;
            result = result * 10;
            result += value;
        }
        
        return result;
    }
}
